<?php
$server = new swoole_server("0.0.0.0", 8081);
$server->set(array(
    "open_eof_check"=>true,
    'package_eof' => "\r\n\r\n",
    'open_eof_split' => true,
));
$server->on('connect', function ($server, $fd){
    echo "connection open: {$fd}\n";
});
$server->on('receive', function ($server, $fd, $reactor_id, $data) {
    echo "received:" . $data;
    $server->close($fd);
    file_put_contents('./response.json', $data);
});
$server->on('close', function ($server, $fd) {
    echo "connection close: {$fd}\n";
});
$server->start();
